﻿// Inner Fire 游戏引擎库
// UIPrefab - 用于UI的Prefab
//
// Copyright (c) 2025 by 尔西大帝. All rights reserved.
//
// 用于UI的Prefab
//
// Author: 尔西大帝
// Email: 2670613871@qq.com
// Created: 2025-04-24

#include "ui_prefab.h"

namespace ifire::game {
ifire::game::UIPrefab::UIPrefab(ConfigManager* manager, const XmlNode& node)
    : ConfigInfo(manager, node("Name")), type(node("Type")) {
  // 根据类型决定不同的处理
  if (IsLabel()) {
    label_info_ = std::make_unique<ui::LabelInfo>(node);
  } else if (IsImage()) {
    image_info_ = std::make_unique<ui::ImageInfo>(node);
  } else if (IsButton()) {
    button_info_ = std::make_unique<ui::ButtonInfo>(node);
  }
}

bool UIPrefab::IsLabel() const {
  const static ikit::sstr TYPE_LABEL = "Label";
  return type == TYPE_LABEL;
}

bool UIPrefab::IsImage() const {
  const static ikit::sstr TYPE_IMAGE = "Image";
  return type == TYPE_IMAGE;
}

bool UIPrefab::IsButton() const {

  const static ikit::sstr TYPE_BUTTON = "Button";
  return type == TYPE_BUTTON;
}

} // namespace ifire::game
